<template>
  <div class="container">
    <div class="header" :style="headerBg">
      <div>{{prodata.productName}}</div>
      <div>{{prodata.interestRate}}</div>
      <div>年利率</div>
    </div>

    <!-- echars 图表 -->
     <div class="title">
       <div>本基金</div>
     </div>
    <div class="charts">
     
      <div id="myChart"></div>
    </div>

     <div class="title">
       <div>产品概况</div>
     </div>
    <div class="charts">
      <div class="gaikuang">
        <div>产品编号</div>
        <div>{{prodata.productCode}}</div>
      </div>
      
           <div class="gaikuang">
        <div>产品名称</div>
        <div>{{prodata.productName}}</div>
      </div>

           <div class="gaikuang">
        <div>产品类型</div>
        <div>{{prodata.productTypeName}}</div>
      </div>

           <div class="gaikuang">
        <div>产品周期</div>
        <div>{{prodata.interestCycle}}</div>
      </div>
    </div>
       <!-- v-if="btnShow" -->
    <div class="foot"  v-if="btnShow">
            <div>
           <!-- <img src="./../assets/images/product/phone.png" alt="">
        <div>手机</div> -->
      </div>
      <div>
        <!-- <img src="./../assets/images/product/weixin.png" alt="">
        <div>微信</div> -->
      </div>

      <div >
        <van-button type="default" color="#DBB47F" style="width:100%" @click="submit(prodata.id,prodata.productName)">提 交 申 请</van-button>
      </div>
    </div>
  </div>
</template>
<script>
import { Toast } from "vant";
import Api from "./../api/api";
export default {
  data() {
    return {
      prodata:{},
      btnShow:false,
      headerBg: {
        backgroundImage:
          "url(" + require("./../assets/images/product/bg.png") + ")",
        backgroundRepeat: "no-repeat",
        backgroundSize: "100% 100%"
      },
    }
  },
  methods: {
    drawLine() {
      let myChart = this.$echarts.init(document.getElementById("myChart"));
      setTimeout(() => {
        myChart.setOption({
          xAxis: {
            type: "category",
            data: ["18.12", "19.02", "19.06", "19.10", "20.02",], 
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            }
          },
          yAxis: {
            type: "value",
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            }
          },
          grid: {
            x: 50,
            y: 10,
          },

          series: [
            {
              symbol: "circle",
              symbolSize: 10, //设定实心点的大小
              itemStyle: {
                normal: {
                  color: "#DBB47F", //改变折线点的颜色
                  lineStyle: {
                    color: "#DBB47F" //改变折线颜色
                  }
                }
              },
              data:[2, 1, 3, 4, 5,],
              type: "line"
            }
          ]
        });
      }, 1000);
    },
    getData(){
      
      this.$axios
        .post(Api.HTTP.bind,{
          wechatOpenId: localStorage.getItem("openId"),
          code: this.number
        })
        .then((res)=> {
          if (res.success) {
            Toast("绑定成功");
            setTimeout(() => {
              this.$router.push({ path: "/ManagerHomePage" });
            }, 1500);
          }else{
             Toast("绑定失败");
          }
        })
        .catch(function(error) {
           Toast("网络错误");
        });
    },
    submit(id,name){
         this.$router.push({
          path: "/SubProduct",
          query: {
            id: id,
            name:name
          }
        });
    }
  },
  activated(){
      this.pubilcM.setTitle("产品详情");
    if(typeof(this.$route.query.item) == 'object'){
       this.prodata =  this.$route.query.item;
    }
  },
  mounted() {
     this.pubilcM.setTitle("产品详情");
    this.drawLine();
    this.prodata = this.$route.query.item;
    if( localStorage.getItem('customerId') != null ){
      this.btnShow = true;
    }

  }
};
</script>
<style scoped>
.container {
  width: 100%;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  padding-bottom: 1.2rem;
  background: #f5f5f5;
  overflow: hidden;
  overflow-y: auto;
}
.header {
  width: 100%;
  height: 3rem;
  padding: 0.4rem;
  box-sizing: border-box;
  text-align: center;
  color: #fff;
}
.gaikuang{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.1rem
}
.gaikuang div:nth-child(1){
  font-size: 0.25rem;
  color: #999
}
.gaikuang div:nth-child(2){
  font-size: 0.27rem;

}
.header div:nth-child(1) {
  margin-bottom: 0.3rem;
}
.header div:nth-child(2) {
  margin-bottom: 0.2rem;
  font-size: 0.6rem;
}
.charts {
  padding: 0.2rem;
  box-sizing: border-box;
  background: #fff;
  margin-bottom: 0.2rem
}
#myChart {
  width: 100%;
  height: 3rem;
}
.title {
  
  box-sizing: border-box;
  font-weight: bold;
    padding: 0.2rem;
  box-sizing: border-box;
  background: #fff;
}
.title div{
  border-left: 4px solid #dbb47f;
 font-size: 0.27rem;
 padding-left: 0.2rem;
}
.foot{
  padding: 0.2rem;
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  display: flex;
  justify-items: center;
  box-sizing: border-box;
  height: 1.2rem;
  width: 100%;
  position: fixed;
  bottom: 0%;
  background: #fff;
  justify-content: space-between;
}
.foot div:nth-child(1){
  width: 0.45rem;
   text-align: center;
}
.foot img{
 width: 0.45rem;
  text-align: center;
    height: 0.4rem;

}
.foot div:nth-child(1){
    width: 15%;
  font-size: 0.2rem;
   text-align: center;
}
.foot div:nth-child(2){
 
  font-size: 0.2rem;
   text-align: center;
}
.foot div:nth-child(3){
  width: 60%;
}
</style>